package com.journaldev.spring.model;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@SuppressWarnings("serial")
@Embeddable
public class PrescriptionMedicineId implements java.io.Serializable {
	
	private Medicine medicine;
    private Prescription prescription;
 
	@ManyToOne
	public Medicine getMedicine() {
		return medicine;
	}
 
	public void setMedicine(Medicine med) {
		this.medicine = med;
	}
 
	@ManyToOne
	public Prescription getPrescription() {
		return prescription;
	}
 
	public void setPrescription(Prescription oresc) {
		this.prescription = oresc;
	}
 
	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        PrescriptionMedicineId that = (PrescriptionMedicineId) o;
 
        if (medicine != null ? !medicine.equals(that.medicine) : that.medicine != null) return false;
        if (prescription != null ? !prescription.equals(that.prescription) : that.prescription != null)
            return false;
 
        return true;
    }
 
    public int hashCode() {
        int result;
        result = (medicine != null ? medicine.hashCode() : 0);
        result = 31 * result + (prescription != null ? prescription.hashCode() : 0);
        return result;
    }

}
